//
//  Loan_UploadPicViewController.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/9/13.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Loan_UploadPicViewController.h"
#import "ZYCustomCameraVC.h"
#import "Loan_FaceRecognitionViewController.h"

@interface Loan_UploadPicViewController ()
@property(nonatomic,strong)UIScrollView *myScrollView;
@property(nonatomic,strong)UIImageView *userImageView;
@property(nonatomic,strong)UIButton *picBtn;
@property(nonatomic,strong)UIButton *nextBtn;

//未拍页面文字控件
@property(nonatomic,strong)UILabel *tip_upLabel;
@property(nonatomic,strong)UILabel *tip_bottomLabel1;
@property(nonatomic,strong)UILabel *tip_botomLabel;
//有拍照图片页面控件
@property(nonatomic,strong)UIButton *successBtn;
@property(nonatomic,strong)UILabel *tipLabel;

@property(nonatomic,assign)BOOL isHavePic;


@end

@implementation Loan_UploadPicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"上传大头照";
    self.isHavePic = NO;
    self.view.backgroundColor = ListMaoBackgroundColor;
    [self initViews];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(UserHeaderIcon:) name:UserHeaderIconNotification object:nil];
}

-(void)UserHeaderIcon:(NSNotification *)sender{
    UIImage *image = sender.userInfo[@"pic_image"];
    self.userImageView.image = image;
    self.isHavePic = YES;
}
-(void)selectPicBtnAction{
    ZYCustomCameraVC *cameraVC = [[ZYCustomCameraVC alloc]init];
    [self presentViewController:cameraVC animated:YES completion:nil];
}

-(void)nextBtnAction{
    Loan_FaceRecognitionViewController *faceVC = [[Loan_FaceRecognitionViewController alloc]init];
    [self.navigationController pushViewController:faceVC animated:YES];
    
}

-(void)initViews{
    
    UIView *contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidthMao, 600)];
    contentView.backgroundColor = [UIColor whiteColor];
    
    UIView *whiteView = [[UIView alloc]init];
    whiteView.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:whiteView];
    [whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(contentView);
        make.height.mas_offset(@365);
    }];
    
    UIView *progressView = [[UIView alloc]init];
    progressView.backgroundColor = ThemeMaoColor;
    [self.view addSubview:progressView];
    [progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(self.view);
        make.width.mas_offset(@(ScreenWidthMao/6*3));
        make.height.mas_offset(@2);
    }];
    
    _userImageView = [[UIImageView alloc]init];
    _userImageView.image = [UIImage imageNamed:@"loan_datouzhao"];
    _userImageView.userInteractionEnabled = YES;
    [contentView addSubview:_userImageView];
    [self.userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(contentView);
        make.top.mas_equalTo(contentView.mas_top).offset(110);
        make.width.height.mas_offset(@200);
    }];
    
    _picBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_picBtn addTarget:self action:@selector(selectPicBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [contentView addSubview:_picBtn];
    [_picBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.centerX.mas_equalTo(self.userImageView);
        make.width.height.mas_offset(@50);
    }];
    
    _tip_upLabel = [[UILabel alloc]init];
    _tip_upLabel.text = @"请遵循要求拍摄本人面部照片否则会导致借款失败";
    _tip_upLabel.textColor = ThemeMaoBackgroundColor;
    _tip_upLabel.font = [UIFont systemFontOfSize:15];
    _tip_upLabel.numberOfLines = 0;
    _tip_upLabel.textAlignment = NSTextAlignmentCenter;
    [contentView addSubview:_tip_upLabel];
    [self.tip_upLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(contentView);
        make.top.mas_equalTo(contentView.mas_top).offset(35);
        make.width.mas_offset(@200);
    }];
    
    _tip_bottomLabel1 = [[UILabel alloc]init];
    _tip_bottomLabel1.text = @"拍摄要求：";
    _tip_bottomLabel1.textColor = ThemeTintFontColor;
    _tip_bottomLabel1.font = [UIFont systemFontOfSize:15];
    [contentView addSubview:_tip_bottomLabel1];
    [self.tip_bottomLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(contentView.mas_left).offset(25);;
        make.top.mas_equalTo(self.userImageView.mas_bottom).offset(31);
        make.height.mas_offset(@15);
    }];
    
    _tip_botomLabel = [[UILabel alloc]init];
    _tip_botomLabel.text = @"五官清晰可见，无遮挡保证头部在线框内，背景单一，光线充足";
    _tip_botomLabel.textColor = ThemeTintFontColor;
    _tip_botomLabel.font = [UIFont systemFontOfSize:14];
    _tip_botomLabel.numberOfLines = 0;
    [contentView addSubview:_tip_botomLabel];
    [self.tip_botomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.tip_bottomLabel1);
        make.top.mas_equalTo(self.tip_bottomLabel1.mas_bottom).offset(10);
        make.right.mas_equalTo(contentView.mas_right).offset(-25);
    }];
    
    _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [_nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_nextBtn setBackgroundColor:ThemeMaoColor];
    [_nextBtn setBackgroundImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    _nextBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _nextBtn.layer.masksToBounds = YES;
    _nextBtn.layer.cornerRadius = 4;
    [_nextBtn addTarget:self action:@selector(nextBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [contentView addSubview:_nextBtn];
    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.tip_botomLabel);
        make.top.mas_equalTo(self.tip_botomLabel.mas_bottom).offset(25);
        make.height.mas_offset(@44);
    }];
    
    
    
    
    self.myScrollView = [[UIScrollView alloc]initWithFrame:CGRectZero];
    self.myScrollView.contentSize = contentView.frame.size;
    self.myScrollView.showsVerticalScrollIndicator = NO;
    self.myScrollView.backgroundColor = [UIColor whiteColor];
    [self.myScrollView addSubview:contentView];
    [self.view addSubview:self.myScrollView];
    [self.myScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(2);
        make.bottom.mas_equalTo(self.view).offset(SafeAreaBottomHeight);
    }];
    
}

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
